package com.example.demo.service;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.example.demo.bean.Goods;
import com.example.demo.dao.GoodsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional //本地事务
public class GoodsService {

    @Autowired
    private GoodsDao goodsDao;
//    @LcnTransaction//分布式事务 加上此注解会回滚服务消费者
    public boolean jian() {
        Goods goods = goodsDao.findById("123").get();
        goods.setCount(goods.getCount() - 1);
        goodsDao.save(goods);
        int i=1/0;
        return true;
    }
}
